package com.zhihuixingguang.login;

import com.zhihuixingguang.util.MD5;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
	
@Setter
@Getter
@Slf4j
@NoArgsConstructor
public class TicketCallBackReq extends BaseParam{

	private String ticket;
	
	private String sign;
	
	private String openid;

	/**
	 * 校验签名
	 */
	public void checSign(String appsecret) {
		String key = getAppid()+getNonce()+ticket+getTime()+appsecret;
		if(!sign.equals(MD5.getMD5(key))) {
			log.info("签名校验失败，本地签名值：{}，参数签名值：{}",MD5.getMD5(key),sign);
			throw new RuntimeException("签名校验失败");
		}
	}
	



	public TicketCallBackReq(String appid, String nonce, Long time, String ticket, String sign, String openid) {
		super(appid, nonce, time);
		this.ticket = ticket;
		this.sign = sign;
		this.openid = openid;
	}
	
	
	
}
